package com.weirdor.wxchat.www.web;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.weirdor.wxchat.module.entity.QywxNewsitem;
import com.weirdor.wxchat.module.service.IQywxNewsitemService;
import com.weirdor.wxchat.support.utils.R;
import com.xiaoleilu.hutool.convert.Convert;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;




/**
 * 图文素材新闻
 * 
 * @author weirdor
 * @email 17996422@qq.com
 * @date 2017-12-01 22:07:17
 */
@RestController
@RequestMapping("/wxchat/qywxnewsitem")
public class QywxNewsitemController {
	@Autowired
	private IQywxNewsitemService qywxNewsitemService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("wxchat:qywxnewsitem:list")
	public R list(@RequestParam Map<String, Object> params){
		EntityWrapper<QywxNewsitem> wrapper = new EntityWrapper<QywxNewsitem>();
		Page<QywxNewsitem> pageUtil=qywxNewsitemService.selectPage(new Page<QywxNewsitem>(Convert.toInt(params.get("page")),Convert.toInt(params.get("limit"))),wrapper);
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("wxchat:qywxnewsitem:info")
	public R info(@PathVariable("id") String id){
		QywxNewsitem qywxNewsitem = qywxNewsitemService.selectById(id);
		return R.ok().put("qywxNewsitem", qywxNewsitem);
	}

	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("wxchat:qywxnewsitem:save")
	public R save(@RequestBody QywxNewsitem qywxNewsitem){
		qywxNewsitemService.insert(qywxNewsitem);
		return R.ok();
	}
//
//	/**
//	 * 修改
//	 */
//	@RequestMapping("/update")
//	@RequiresPermissions("wxchat:qywxnewsitem:update")
//	public R update(@RequestBody QywxNewsitemEntity qywxNewsitem){
//		qywxNewsitemService.update(qywxNewsitem);
//
//		return R.ok();
//	}
//
//	/**
//	 * 删除
//	 */
//	@RequestMapping("/delete")
//	@RequiresPermissions("wxchat:qywxnewsitem:delete")
//	public R delete(@RequestBody String[] ids){
//		qywxNewsitemService.deleteBatch(ids);
//
//		return R.ok();
//	}
//
}
